package com.ha8.netease
{
	import com.ha8.netease.controllers.AttentionCommand;
	import com.ha8.netease.controllers.CreateCommentCommand;
	import com.ha8.netease.controllers.CreatePublishViewCommand;
	import com.ha8.netease.controllers.CreateRepostCommand;
	import com.ha8.netease.controllers.CreateSearchViewCommand;
	import com.ha8.netease.controllers.CreateSuggestionsCommand;
	import com.ha8.netease.controllers.OpenViewerCommand;
	import com.ha8.netease.controllers.UpdateAppCommand;
	import com.ha8.netease.models.WeiboProxy;
	import com.rogo.mvc.sub.facade.Facade;
	
	/**
	 * 全局MVC总控
	 * 
	 * 单例
	 * 
	 * @author rogo
	 */	
	public class AppFacade extends Facade
	{
		public function AppFacade()
		{
			super();
		}
		
		//--------------------------------------------------------------------------
		//
		//  Constants
		//
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//
		//  Variables
		//
		//--------------------------------------------------------------------------
		
		private static var instance:AppFacade;
		
		//--------------------------------------------------------------------------
		//
		//  Overridden Methods
		//
		//--------------------------------------------------------------------------
		
		/**
		 * 初始控制层
		 */		
		override protected function initController():void
		{
			super.initController();
			
			registerCommand(PublicNotify.CREATE_SEARCH_PAGE, CreateSearchViewCommand);
			registerCommand(PublicNotify.CREATE_PUBLISH_PAGE, CreatePublishViewCommand);
			registerCommand(PublicNotify.OPEN_IMAGE_VIEWER, OpenViewerCommand);
			registerCommand(PublicNotify.CREATE_REPOST_VIEW, CreateRepostCommand);
			registerCommand(PublicNotify.CREATE_COMMENT_VIEW, CreateCommentCommand);
			registerCommand(PublicNotify.OPEN_SUGGESTIONS_NOTIFY, CreateSuggestionsCommand);
			registerCommand(PublicNotify.UPDATE_APP, UpdateAppCommand);
			registerCommand(PublicNotify.ATTENTION_NOTIFY, AttentionCommand);
		}
		
		/**
		 * 初始数据代理层
		 */		
		override protected function initModel():void
		{
			super.initModel();
			
			registerProxy(new WeiboProxy());
		}
		
		//--------------------------------------------------------------------------
		//
		//  Methods
		//
		//--------------------------------------------------------------------------
		
		public static function getInstance():AppFacade
		{
			if (!instance)
				instance = new AppFacade();
			return instance;
		}
		
	}
}